﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;

namespace XRoute.DataExchange
{
    [ServiceContract(CallbackContract = typeof(IDataExchangeServiceCallback))]
    public interface IDataExchangeService
    {
        /// <summary>
        /// Connects the calling client to the service.
        /// </summary>
        /// <param name="clientMoniker">A free-form text used to identify the client in
        /// log messages and debug output. Usually the client application name.</param>
        /// <returns>A task that yields the session id the client may use when
        /// issueing further calls to the service.</returns>
        [OperationContract]
        Task<string> ConnectAsync(string clientMoniker);

        [OperationContract]
        Task<BoardContract> GetBoardAsync(string sid);

        [OperationContract]
        Task SetBoardAsync(string sid, BoardContract document);

        [OperationContract(IsOneWay = true)]
        void Disconnect(string sid);
    }

    public interface IDataExchangeServiceCallback
    {
        [OperationContract(IsOneWay = true)]
        void NotifyDocument(BoardContract document);
    }
}
